import numpy as np

class DataUtil(object):

    def get_dataset(name, path, train_num=None, tar_idx=None, shuffle=True):
        x = []

        with open(path, "r", encoding="utf8") as file:

            # if "balloon" in name:
            if True:
                for sample in file:
                    x.append(sample.strip().split(","))

        if shuffle:
            np.random.shuffle(x)

        tar_idx = -1 if tar_idx is None else tar_idx
        y = np.array([xx.pop(tar_idx) for xx in x])
        x = np.array(x)

        if train_num is None:
            return x, y

        return (x[:train_num], y[:train_num]), (x[train_num:], y[train_num:])
